home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / misc / VMM_src.lha / VMM / tools / VMMUsageCLI.c < prev   
Encoding:
C/C++ Source or Header  |  1995-12-16  |  1.4 KB  |  68 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <exec/lists.h>
  4. #include <dos/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. #ifdef __GNUC__
  10. #include "../include/VMM_Stat.h"
  11. #else
  12. #include "/include/VMM_Stat.h"
  13. #endif
  14.  
  15. void main (void)
  16.  
  17. {
  18. struct VMUsageMsg *UsageMsg;
  19. LONG   VMSignal;
  20. struct MsgPort *VMPort;
  21. BOOL success = FALSE;
  22. struct TaskVMUsage *tmp;
  23.  
  24. if ((UsageMsg = AllocMem (sizeof (struct VMUsageMsg), MEMF_PUBLIC)) == NULL)
  25.   {
  26.   printf ("No mem\n");
  27.   exit (10);
  28.   }
  29.  
  30. if ((VMSignal = AllocSignal (-1L)) == -1L)
  31.   {
  32.   printf ("No signal\n");
  33.   FreeMem (UsageMsg, sizeof (struct VMUsageMsg));
  34.   exit (10);
  35.   }
  36.  
  37. UsageMsg->VMMessage.mn_Length = sizeof (struct VMUsageMsg);
  38. UsageMsg->Sender      = FindTask (NULL);
  39. UsageMsg->Command     = VMCMD_AskVMUsage;
  40. UsageMsg->ReplySignal = VMSignal;
  41.  
  42. Forbid ();
  43. if ((VMPort = FindPort ("VMM_Port")) != NULL)
  44.   {
  45.   PutMsg (VMPort, (struct Message*)UsageMsg);
  46.   success = TRUE;
  47.   }
  48. else
  49.   printf ("VMM is not running\n");
  50.  
  51. Permit ();
  52.  
  53. if (success)
  54.   {
  55.   Wait (1L << VMSignal);
  56.   while ((tmp = (struct TaskVMUsage*)RemHead (UsageMsg->TaskList)) != NULL)
  57.     {
  58.     printf ("%-30s %8ld\n", tmp->vu_Node.ln_Name, tmp->VMInUse);
  59.     FreeMem (tmp, tmp->FreeSize);
  60.     }
  61.   FreeMem (UsageMsg->TaskList, sizeof (struct List));
  62.   }
  63.  
  64. FreeMem (UsageMsg, sizeof (struct VMUsageMsg));
  65. FreeSignal (VMSignal);
  66. exit (0);
  67. }
  68.